﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace DigitalAmele.WebApp.s3capcha
{
    public partial class wucCapcha : System.Web.UI.UserControl
    {
        public void SetIt()
        {
            int USessionId;
            CapchaHTML.Text = s3capcha.GetHtmlCodes(ResolveClientUrl("~/s3capcha"), out USessionId);
            Session[s3capcha.s3name] = USessionId;
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
                SetIt();
        }

        public bool IsValid
        {
            get
            {
                bool res = s3capcha.Verify(Session[s3capcha.s3name], Request.Form[s3capcha.s3name]);
                SetIt();
                return res;
            }
        }
    }
}